//
//  WFBaseCollectionView.m
//  谷居
//
//  Created by dllo on 16/6/24.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFBaseCollectionView.h"

@implementation WFBaseCollectionView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout {
    self = [super initWithFrame:frame collectionViewLayout:layout];
    if (self) {
        [self setColor];
        [self addObserver];
    }
    return self;
}
- (void)setColor {
    if (!IS_LONG) {
        self.backgroundColor = DAY_COLOR;
    } else {
        self.backgroundColor = NIGHT_COLOR;
    }
    
}

- (void)addObserver {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeToNight:) name:@"夜间模式" object:nil];
    
}
-(void)changeToNight:(NSNotification *)sender {
    if (!IS_LONG) {
        self.backgroundColor = NIGHT_COLOR;
    } else {
        self.backgroundColor = DAY_COLOR;
    }
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];

    [super dealloc];
}
@end
